import { fetchCourierAPI, fetchCourierListAPI } from '@/api/employee/deliverymanAPI'

const actions = {
  /*
  *获取快递员分页数据的action
  *  */
  async fetchCourierListAction(context, pageParams) {
    const { data } = await fetchCourierListAPI(pageParams)
    context.commit('setCourierListMutation', data)
  },
  /*
  * 获取快递员详情的action
  *  */
  async fetchCourierAction(context, id) {
    const { data } = await fetchCourierAPI(id)
    return data
  }
}
const mutations = {
  /*
  *设置快递员分页数据的mutation
  *  */
  setCourierListMutation(state, { counts, items }) {
    state.courierList = items
    state.counts = Number(counts)
  }
}
const state = () => {
  return {
    courierList: [],
    counts: 0
  }
}

export default {
  actions,
  mutations,
  state,
  namespaced: true
}
